package SwingView.Quiz;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;

import javax.swing.JOptionPane;

import JDBC.InstructorLectureActivities;
import JDBC.InstructorQuizActivities;
import SwingController.CmsPresenter;
import SwingModel.CmsInstructor;
import SwingModel.CmsLecture;
import SwingModel.CmsQuiz;
import SwingModel.CmsUser;
import SwingView.CmsMainView;

public class ALQuizDelete implements ActionListener{

	private CmsQuiz quiz;
	
	public ALQuizDelete(CmsQuiz quiz){
		this.quiz = quiz;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		
		System.out.println("Inside actionPerformed of ALQuizDelete ");
		CmsUser user = CmsPresenter.user;
		CmsMainView mainView = CmsPresenter.mainView;
		
		
        CmsInstructor instructor =  (CmsInstructor)CmsPresenter.user;
		
        int returnVal = JOptionPane.showConfirmDialog(CmsPresenter.mainView, 
        											"Do you want to delete this quiz:\n" + quiz.getQuizTitle() + "\n");
        
        if(returnVal == JOptionPane.YES_OPTION){
        	//instructor deleteQuiz
    		InstructorQuizActivities.deleteQuiz(quiz.getQuizID());
    		
    		//display lecture instructor Page
    		
    		mainView.displayQuizInstructorPage(InstructorQuizActivities.getListOfQuiz(user.getSelectedCourse().getCourseID()));
    		
    		System.out.println("ALQuizDelete : Delete this quizID - " + quiz.getQuizID());
        }
		

}
	}

